﻿using System;
using System.Collections.Generic;
using System.Text;
using Quanlynhasach.hethongluutru;
using Quanlynhasach.hethongxuly;
using System.Data;

namespace Quanlynhasach.hethongluutru
{
    class TacGiaDAO
    {
        public static DataTable LayDanhSachTacGia()
        {
            string sql;
            sql = "Select * From TacGia ";
            DataTable dt = database.ExcuQuery(sql);

            return dt;
        }

        public static String LayTenTacGia(String mtg)
        {
            string sql;
            sql = "Select TenTacGia From TacGia Where MaTacGia= " + mtg;
            DataTable dt = database.ExcuQuery(sql);
            String ten = dt.Rows[0].ItemArray[0].ToString();

            return ten;
        }

        public void ThemTacGia(TacGiaDTO tgs)
        {
            string sql;
            sql = "Insert into TacGia(TenTacGia) values ('" + tgs.m_TenTacGia + "')";
            database.ExcuNonQuery(sql);
        }

        public void XoaTacGia(TacGiaDTO tgs)
        {
            string sql;
            sql = "Delete From TacGia Where MaTacGia =" +tgs.m_MaTacGia.ToString();
            database.ExcuNonQuery(sql);
        }

        public void SuaTacGia(TacGiaDTO tgs)
        {
            string sql;
            sql = "Update TacGia Set TenTacGia='" + tgs.m_TenTacGia +"'";
            sql += " Where MaTacGia = " + tgs.m_MaTacGia.ToString();
            database.ExcuNonQuery(sql);
        }

       

    }
}